import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from "../views/login/Login.vue"
import User from "../views/User/users.vue"
import Categories from "../views/Categories/categories.vue"
import Reports from "../views//Reports/reports.vue"
import Order from "../views/Order/orders.vue"
import Params from "../views/Params/params.vue"
import Goods from "../views/Goods/goods.vue"
import Add from "../views/Goods/add.vue"
import Role from "../views/Role/roles.vue"
import Roles from "../views/Roles/Roles.vue"
import Jurisdiction from "../views/Jurisdiction/rights.vue"
import Welcome from "../views/Welcome/Welcome.vue"
Vue.use(VueRouter)
const routes = [{
        path: "/Login",
        component: Login,
        name: "Login"
    },
    { path: "/", redirect: "Login" },
    // {
    //     path: "/User",
    //     component: User,
    //     beforeEnter: (to, from, next) => {
    //         console.log(to, "to");
    //         console.log(from, "from");
    //         // 只判断是否登陆成功就可以了
    //         if (localStorage.getItem("login")) {
    //             next()
    //         } else {
    //             next("/login")
    //         }
    //     }
    // },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        redirect: {
            path: '/Welcome'
        },
        children: [{
                path: "/users",
                name: "User",
                component: User
            },

            {
                path: "/categories",
                name: "Categories",
                component: Categories
            },
            {
                path: "/roles",
                name: 'Role',
                component: Role
            },
            {
                path: "/Welcome",
                name: "Welcome",
                component: Welcome
            },
            {
                path: "/rights",
                name: 'Jurisdiction',
                component: Jurisdiction
            },
            {
                path: "/Roles",
                name: 'Roles',
                component: Roles
            },
            {
                path: "/goods",
                name: 'Goods',
                component: Goods
            },
            {
                path: "/add",
                name: 'Add',
                component: Add
            },
            {
                path: "/params",
                name: 'Params',
                component: Params
            },
            {
                path: "/orders",
                name: 'Order',
                component: Order
            },
            {
                path: "/reports",
                name: 'Reports',
                component: Reports
            }
        ]
    }
]


const router = new VueRouter({
    routes
})

export default router